package com.jinke.api.modules.app.service;

import com.jinke.api.common.api.CommonResult;
import com.jinke.api.modules.app.controller.res.PriceSurchargeImportDto;
import com.jinke.api.modules.app.controller.res.ZipCodeImportDto;
import com.jinke.api.modules.app.model.PriceSurcharge;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jinke.api.modules.app.response.SelfDefinedPriceResponse;
import com.jinke.api.modules.third.ezeeship.model.request.EstimateRateRequest;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 自定义价格-附加费表 服务类
 * </p>
 *
 * @author husuruo
 * @since 2024-07-30
 */
public interface PriceSurchargeService extends IService<PriceSurcharge> {

    CommonResult<String> importPriceSurcharge(PriceSurchargeImportDto importDto) throws IOException;

    /**
     * 根据包裹信息获取附加费
     * @param request
     * @return
     */
    List<PriceSurcharge> getRateFromPriceSurcharge(EstimateRateRequest request,String zone);

    /**
     * 距离收费项
     * @param importDto
     * @return
     * @throws IOException
     */
    CommonResult<String> importZipCode(ZipCodeImportDto importDto) throws IOException;
        void checkDistanceSurcharge(String serviceCode, StringBuilder stringBuilder,
                                    List<PriceSurcharge> tipPriceSurchargeList, Map<String, List<PriceSurcharge>> groupedByItem,
                                    String zipCode, Boolean isResidential);

    /**
     * 重量收费项
     * @param zone
     * @param serviceCode
     * @param stringBuilder
     * @param tipPriceSurchargeList
     * @param groupedByItem
     * @param parcelWeight
     */
    void checkWeightSurcharge(String zone, String serviceCode, StringBuilder stringBuilder, List<PriceSurcharge> tipPriceSurchargeList, Map<String, List<PriceSurcharge>> groupedByItem, BigDecimal parcelWeight);

    /**
     * 大小收费项
     * @param selfDefinedPriceResponse
     * @param zone
     * @param serviceCode
     * @param stringBuilder
     * @param tipPriceSurchargeList
     * @param groupedByItem
     * @param parcelLength
     * @param parcelHeight
     * @param parcelWidth
     * @param parcelWeight
     * @param isResidential
     * @return
     */
    Integer checkOversizeSurcharge(SelfDefinedPriceResponse selfDefinedPriceResponse, String zone, String serviceCode, StringBuilder stringBuilder, List<PriceSurcharge> tipPriceSurchargeList, Map<String, List<PriceSurcharge>> groupedByItem, BigDecimal parcelLength, BigDecimal parcelHeight, BigDecimal parcelWidth, BigDecimal parcelWeight, Boolean isResidential);

    /**
     * 处理峰值相关的条件
     *
     * @param groupedByItem    分组后的项目数据
     * @param tipPriceSurchargeList  附加费列表
     * @param serviceCode    服务代码
     * @param zone    区域
     */
    void handlePeakConditions(Map<String, List<PriceSurcharge>> groupedByItem, List<PriceSurcharge> tipPriceSurchargeList, String serviceCode, String zone, Integer isOverSize, Boolean isResidential);

    void validSurcharge(List<PriceSurcharge> tipPriceSurchargeList, List<PriceSurcharge> re, String serviceCode, String zone, String residential_charge);
}
